#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0" }
param(
    $ModuleName  = "dbatools",
    $CommandName = "Get-DbaInstanceProtocol",
    $PSDefaultParameterValues = $TestConfig.Defaults
)

Describe $CommandName -Tag UnitTests {
    Context "Parameter validation" {
        It "Should have the expected parameters" {
            $hasParameters = (Get-Command $CommandName).Parameters.Values.Name | Where-Object { $PSItem -notin ("WhatIf", "Confirm") }
            $expectedParameters = $TestConfig.CommonParameters
            $expectedParameters += @(
                "ComputerName",
                "Credential",
                "EnableException"
            )
            Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $hasParameters | Should -BeNullOrEmpty
        }
    }
}

Describe $CommandName -Tag IntegrationTests {
    Context "Command actually works" {
        BeforeAll {
            $allResults = Get-DbaInstanceProtocol -ComputerName $TestConfig.instance1, $TestConfig.instance2
            $tcpResults = $allResults | Where-Object Name -eq "Tcp"
        }

        It "shows some services" {
            $allResults.DisplayName | Should -Not -BeNullOrEmpty
        }

        It "can get TCPIP" {
            foreach ($result in $tcpResults) {
                $result.Name -eq "Tcp" | Should -Be $true
            }
        }
    }
}